﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Frontend.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="CphTitleContent" ContentPlaceHolderID="TitleContent" runat="server">
    Thanh toán
</asp:Content>
<asp:Content ID="CphHeadContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="/Scripts/Grid/js/i18n/grid.locale-en.js" type="text/javascript"></script>    
    <script src="/Scripts/Grid/js/jquery.jqGrid.js" type="text/javascript"></script>
    <script src="/Scripts/Grid/js/grid.base.js" type="text/javascript"></script>
    <link href="/Scripts/Grid/themes/ui.jqgrid.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            //add method valid fone
            jQuery.validator.addMethod(
            "validatePhone", function (value) {
                return JS_LIB.isPhone(value);
            }, 'Chỉ được nhập các ký tự : 0123456789.,()-+ ');

            jQuery("#list").jqGrid({
                url: '/OrderView/GetListJQGridPayment/',
                datatype: 'json',
                mtype: 'GET',
                colNames: ['ID', 'Hình', 'Tên Sản Phẩm', 'Giá', 'Số Lượng', 'Thành Tiền', 'Position'],
                colModel: [
                  { name: 'ID', index: 'ID', align: "center", width: 50, hidden: true },
                  { name: 'Image', index: 'ProductName', align: "center", width: 60, sortable: false },
                  { name: 'ProductName', index: 'ProductName', align: "left", width: 100, sortable: false },
                  { name: 'Price', index: 'Price', align: "center", width: 60, sortable: false },
                  { name: 'Quantity', index: 'Quantity', align: "center", width: 60, sortable: false },
                  { name: 'Subtotal', index: 'Subtotal', align: "center", width: 60, sortable: false },
                  { name: 'Postion', index: 'Postion', align: "left", width: 10, hidden: true, sortable: false}],
                sortname: 'Postion',
                sortorder: "asc",
                viewrecords: true,
                width: 737, height: "100%",
                imgpath: '/scripts/grid/themes/basic/images',
                loadui: 'block'
            });
            $("#btnBack").click(function () {
                JS_LIB.back();
            });

            $("#paymentForm").validate({
                debug: false,
                errorElement: "span",
                errorPlacement: function (error, element) {
                    error.tooltip({
                        bodyHandler: function () {
                            return error.html();
                        }
                    });
                    error.insertAfter(element);
                },
                rules: {
                    Name: {
                        required: true
                    },
                    Address: {
                        required: true
                    },
                    Phone: {
                        required: true,
                        validatePhone: true
                    },
                    Email: {
                        required: true,
                        email:true
                    },
                    txtCapcha: {
                        required: true
                    }
                }
            });
        });
    </script>
    <style type="text/css">
        .ui-jqgrid tr.jqgrow td
        {
            white-space: normal;
        }
    </style>
</asp:Content>
<asp:Content ID="CphMainContent" ContentPlaceHolderID="MainContent" runat="server">
    <%using (Html.BeginForm("Payment", "OrderView", FormMethod.Post, new { id = "paymentForm", @class = "form" }))
      {%>    
    <div class="ccat">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td class="ccat-lft">
                    <div class="cat-header" style="width:190px !important">
                        <span>Danh mục</span>
                    </div>
                    <% Html.RenderPartial("Modules/Mod_SubMenu"); %>
                </td>
                <td class="ccat-rgh">
                    <div class="ccat-breadcrumb">
                        <%= (string)ViewData["NavigationLink"]%>
                    </div>
                    <div class="ccat-partner">
                        <div class="clist">
                            <table id="list" class="scroll">
                            </table>
                            <table width="737px">
                                <tr>
                                    <td style="text-align: right; width: 80%; font-size: large">
                                        <b>Tổng tiền:&nbsp;&nbsp;&nbsp; </b>
                                    </td>
                                    <td style="text-align: left; width: 20%; font-size: large">
                                        <b style="color: Red">
                                            <%=ViewData["Total"]%>
                                        </b>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="font-size:30px;font-weight:bold;text-align:center">
                                        <h1> Thanh Toán</h1>
                                    </td>
                                </tr>
                            </table>
                            <%= TempData["Message"] %>
                            <table width="600px">
                                <tr>
                                    <td class="label required">
                                        Họ và tên <span>*</span>
                                    </td>
                                    <td class="input">
                                        <%                                                           
                                            Response.Write(Html.TextBox("Name", ViewData.Model == null ? string.Empty : ((Payment)ViewData.Model).Name , new { @maxlength = "100", @style = "width:200px" }));                                           
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label required">
                                        Địa chỉ <span>*</span>
                                    </td>
                                    <td class="input">
                                        <%                                                           
                                            Response.Write(Html.TextBox("Address", ViewData.Model == null ? string.Empty : ((Payment)ViewData.Model).Address, new { @maxlength = "200", @style = "width:200px" }));                                           
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label required">
                                        Điện thoại <span>*</span>
                                    </td>
                                    <td class="input">
                                        <%                                                           
                                            Response.Write(Html.TextBox("Phone", ViewData.Model == null ? string.Empty : ((Payment)ViewData.Model).Phone, new { @maxlength = "20", @style = "width:200px" }));                                           
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label required">
                                        Email <span>*</span>
                                    </td>
                                    <td class="input">
                                        <%                                                           
                                            Response.Write(Html.TextBox("Email", ViewData.Model == null ? string.Empty : ((Payment)ViewData.Model).Email, new { @maxlength = "100", @style = "width:200px" }));                                           
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        Ghi chú
                                    </td>
                                    <td class="input">
                                        <%                                                           
                                            Response.Write(Html.TextArea("Note", ViewData.Model == null ? string.Empty : ((Payment)ViewData.Model).Note, new { @maxlength = "100", @style = "width:300px" }));                                           
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        Hình thức
                                    </td>
                                    <td class="input">
                                        <%            
                                            bool check = true;
                                            if (ViewData.Model == null)
                                            {
                                                check = true;
                                            }
                                            else if (ViewData.Model != null && ((Payment)ViewData.Model).PaymentType == 1)
                                            {
                                                check = true;
                                            }
                                            else
                                            {
                                                check = false;
                                            }

                                            Response.Write(Html.RadioButton("Payment", "1", check, new { @id = "rbAll" }));
                                            Response.Write("<label for=\"rbAll\">Hình thức chuyển khoản</label>&nbsp;<br/><br/>");
                                            Response.Write(Html.RadioButton("Payment", "2", !check, new { @id = "rbPart" }));
                                            Response.Write("<label for=\"rbPart\">Thanh toán tại nhà</label>");
                                        %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        Mã bảo vệ
                                    </td>
                                    <td>
                                        <img src="/Mabaove" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label required">
                                        Nhập mã bảo vệ <span>*</span>
                                    </td>
                                    <td>
                                        <input type="text" id="txtCapcha" name="txtCapcha" maxlength="10" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        <input type="submit" value="Gửi" style="width:100px" />
                                        <input type="reset" value="Làm lại" style="width:100px"/>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <% } %>
</asp:Content>
